<?php
    require_once ( "../config.php" );
    
    $data = null;
    if ($_REQUEST!=null && isset($_REQUEST["data"]) && is_string($_REQUEST["data"]) ) {
        $data = str_check(strval($_REQUEST["data"]));
    }
    if ($data === null || $data==="" ) {
        $error = new my_error("param_error");
        exit( $error->to_string() );
    }
    $id = get_key();
    $db = new SQLite3('../_db/' . $sqlite_db_name);
    $sql = sprintf("insert into normal(uid,data) values(%s, '%s')", $id, $data);
    $r = $db->exec($sql);
    if ($r==null || $r==FALSE) {
        $error = new my_error("sql_exec_failed");
        exit( $error->to_string() );
    }
    $retval = new my_retval($id);
    exit($retval->to_string());

